# Replication files

## Simple one-line replication

Users in a hurry can simply follow the instructions in 00_main_regressions

## Users with more time

### Prerequisites

This archive uses R, 3.6 or above, GDAL, ogr2ogr, fiona (Python), bash, and the following R packages:
- tidyverse, rgdal, rgeos, sp, sf, data.table, latex2exp, parallel.

MacOS or Linux are recommended. The code may work with Windows and Cygwin but there is no guarantee.

### Large data storage

As often as possible, the archive includes the publicly available files. This is not possible for USGS's Digital Elevation Model as the files are very large. Yet, these files are directly downloadable from the National Map viewer.

In the data archive, look up for the screenshots as "folder_structure.png" that indicate how you should organize your downloads.

### Folder structure

Folders 1_0_ to 4_ provide the entire workflow.

The replication should be contacted folder by folder in sequence.

1_0_hurricane_path:

uses NOAA's Atlantic Hurricane data set to build hurricane wind paths

1_1_elevation_data:

uses USGS' Digital Elevation Model to build elevation by area.

1_2_land_cover:

uses USGS' Land Cover to build wetlands

1_3_classifier_damages:

uses HUD's survey of Sandy damages to build the classifier

1_4_treatment_group:

builds the treatment group at the blockgroup level. This is aggregated later to the ZIP level, which is the level common to HMDA and McDash.

1_prepare_data:

prepares

- HMDA
- Black Knight data
- the ZIP-level historical frequency of hurricanes
- the share of each ZIP in SFHA areas, 
- the ZIP-level Census data, 
- bank characteristics (incl. liquidity), 
- Zillow prices, 
- as well as crosswalks: ZIP to county, tract to ZCTA, Blockgroup to ZCTA, ZIP to CBSA, County to MSA crosswalk.

2_analysis_HMDA:

- produces the graphs of baseline discontinuities (Figures 2 et 3).
- produces the estimation sample for the lending standards regression (Table 2).
- produces the estimation sample for the bunching regression (Table 3).
- produces Table 2.
- produces Table 3.
- produces Table 5.

3_analysis_blackknight:

- produces the black knight estimation sample and produces Table 4.

4_structural_model:

- produces Figures 7, 8, 9.



